const config = require('../../../config/config.local');
const amazonMws = require('amazon-mws')(config.AWSAccessKeyId, config.AWSSecretKey);
amazonMws.setResponseFormat("text");
// const isProduction = process.env.NODE_ENV === 'production';

const d = {};

d.getFeedSubmissionResult = function (seller_id, mws_auth_token, feedSubmissionId, charset=null) {
  console.log('set sellerid:' + seller_id)
  let baseOption = {
    'Version': '2009-01-01',
    'Action': 'GetFeedSubmissionResult',
    'SellerId': seller_id,
    'MWSAuthToken': mws_auth_token,
    'FeedSubmissionId': feedSubmissionId,
    // __CHARSET__: 'ISO-8859-1'
  };
  if (charset){
    baseOption["__CHARSET__"] = charset;
  }
  return amazonMws.feeds.search(baseOption);
};

module.exports = d;